package com.example.myretrofit2.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.example.myretrofit2.R;
import com.example.myretrofit2.common.MyApplication;


public class SearchActiviry extends AppCompatActivity {
    TextView serchBtn;
    EditText keyword;
    ImageView imageView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search_activiry);
        serchBtn = findViewById(R.id.serch_btn);
        keyword =  findViewById(R.id.key_word);
        imageView = findViewById(R.id.title_back);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        serchBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(TextUtils.isEmpty(keyword.getText().toString())){
                    Toast.makeText(MyApplication.getContext(),"请输入关键字", Toast.LENGTH_SHORT).show();
                }else {
                    Intent intent = new Intent();
                    intent.putExtra("goodsName",keyword.getText().toString());
                    intent.setClass(SearchActiviry.this,GoodsList.class);
                    startActivity(intent);
                }
            }
        });
    }
}